package aop03;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import java.lang.reflect.Method;

public class AroundAdvice implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        Object target = invocation.getThis();
        Method method = invocation.getMethod();
        Object[] arguments = invocation.getArguments();
        Object result = null;
        try {
            long l = System.currentTimeMillis();
            result = invocation.proceed();
            long l2 = System.currentTimeMillis();
            System.out.println("后置通知执行，方法执行时间为"+(l2-l)+"毫秒");
        } catch (Throwable throwable) {
            System.out.println("异常通知执行");
        }
        return null;
    }
}
